package com.ndphu.comic.gui.fragment.readnow;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ndphu.comic.R;

public class FragmentReadNow extends Fragment {
	private ViewPager mViewPager;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_read_now, container, false);
		mViewPager = (ViewPager) view.findViewById(R.id.fragment_read_now_pager);
		mViewPager.setAdapter(new PagerAdapter(getFragmentManager()));
		return view;
	}

	public class PagerAdapter extends FragmentStatePagerAdapter {

		public PagerAdapter(FragmentManager fm) {
			super(fm);
		}

		@Override
		public Fragment getItem(int position) {
			switch (position) {
			case 0:
				return new RecentBooksFragment();
			case 1:
				return new FavoriteBooksFragment();
			}
			return null;
		}

		@Override
		public int getCount() {
			return 2;
		}

		@Override
		public CharSequence getPageTitle(int position) {
			switch (position) {
			case 0:
				return "Recent Read";
			case 1:
				return "Favorites";
			default:
				return "UNKNOW";
			}
		}

	}

}
